home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Utilities / BareED / rexx / RemRemarks.rx < prev   
Text File  |  2001-04-06  |  2KB  |  89 lines

  1. /*
  2.     Remove remarks of a Shell or equivalent script (e.g. BareED.cfg)
  3.     Updated: 6-Apr-2001
  4. */
  5.  
  6. BAREED_HOST = GetClip('BAREED')
  7.  
  8. IF BAREED_HOST = '' THEN DO
  9.     CALL SetClip('BAREED')    /* Remove from ClipNode */
  10.     EXIT 5
  11.     END
  12.  
  13. ADDRESS VALUE BAREED_HOST
  14.  
  15. CALL SetClip('BAREED')        /* Remove from ClipNode */
  16.  
  17. OPTIONS RESULTS
  18.  
  19. /* ---------------------- MAIN --------------------- */
  20.  
  21. casetell "WARNING" '0a'x '0a'x "Going to remove remarks off Shell scripts or" '0a'x "assembler source files." '0a'x '0a'x "Sure to go ahead?"
  22. IF RESULT == 0 THEN
  23.     EXIT
  24.  
  25. set findmode
  26. set find string ";"
  27.  
  28. terminate = 0
  29.  
  30. /* Delete remarks */
  31. DO WHILE terminate == 0    /* As long as we find the string */
  32.     find next string
  33.     terminate = RC
  34.     IF RC ~= 0 THEN
  35.         BREAK        /* In case not found */
  36.  
  37.     move cursor left        /* Get character left of semicolon */
  38.     get current char
  39.     thischar = C2D(RESULT)
  40.     move cursor right    /* Move to semicolon */
  41.     cont = 1
  42.  
  43.     IF thischar == 9 | thischar == 32 | thischar == 10    /* Left char of semicolon should be: tab, space or linefeed */
  44.         THEN delete to lineend    /* ...then, we'll remove all - starting with the semicolon to lineend */
  45.             ELSE DO
  46.         cont = 0
  47.     END
  48.  
  49.     IF cont ~= 0 THEN DO        /* Remark removed? */
  50.         DO WHILE cont            /* ...yes */
  51.             move cursor left        /* One position to the left */
  52.             get current char        /* Get the char code */
  53.             thischar = C2D(RESULT)
  54.             IF thischar == 9 | thischar == 32    /* Remove also the char left of (removed) semicolon */
  55.                 THEN delete current char    /* ...if it is a tab or space character */
  56.                     ELSE DO
  57.                 cont = 0
  58.             END
  59.         END
  60.     END
  61.  
  62. END
  63.  
  64. terminate = 0
  65.  
  66. set find string '0a'x||"*"    /* Remove a line if it begins with a asterisk */
  67. move cursor archivestart    /* Start at archive's start */
  68. DO WHILE terminate == 0
  69.     find next string
  70.     terminate = RC
  71.     IF RC ~= 0 THEN
  72.         BREAK
  73.     move cursor right    /* first character (*) in line */
  74.     delete current line
  75.     move cursor left        /* Two steps back */
  76.     move cursor left
  77. END
  78.  
  79. set find string '0a'x||'0a'x    /* Remove paragraphs (double used linefeeds) */
  80. set replace string '0a'x
  81. move cursor archivestart
  82. replace all
  83.  
  84. /* Delete first line of file if it is a remark */
  85. move cursor archivestart
  86. get current char
  87. IF RESULT == ";" | RESULT == "*" THEN
  88.     delete current line
  89.